#ifndef _GL_RENDER_H
#define _GL_RENDER_H_

#pragma warning(disable: 4267)

#include "..\glew\glew.h"

#include "..\rtCommon\Frustum.h"
#include "..\rtCommon\Box.h"
#include "..\rtCommon\RegularGrid_Host.h"
#include "..\rtCommon\RegularGrid.h"
#include "..\rtCommon\Emitter.h"
#include "..\rtCommon\Light.h"
#include "..\rtCommon\SpatialTree.h"

#include "..\xobjIO\XobjIO.h"
#include "..\xobjIO\glMesh.h"
#include "..\xobjIO\glWorld.h"

void glRenderTriangle       (const float4 & v0, 
														 const float4 & v1, 
														 const float4 & v2, 
														 const float3 & clr);

void glRenderTriangle       (const float3 & v0, 
														 const float3 & v1, 
														 const float3 & v2, 
														 const float3 & clr);

void glRender               (CglMesh & mesh, bool bModelSpace);

void glRender               (const CXobjIO & xobj);
void glRenderFaceNormals    (const CXobjIO & xobj);
void glRenderAABB           (const CXobjIO & xobj);

void glRender               (const S_Box & box, float3 * pClr);
void glRender               (const S_Box & box, const float3 & clr);

void glRender               (const S_Box    & box, const matrix4x4 & m4x4, float3 * pClr);

void glRender               (const SGeometryFrustum & geomFrustum);

void glRenderCenter         (const SDistanceField_host & grid, const S_Box              & aabb);

void glRender               (const SDistanceField_host & grid, 
                             const S_Box              & aabb, 
                             const bool                  bRenderSpace);

void glRender               (const Sf_Grid & grid, 
                             const S_Box  & aabb, 
                             bool            bRenderSpace);

void glRender               (const SEmitter        & emitter, 
                             const SFloatGrid_host & grid, 
                             const SFloatGrid_host & u, 
                             const SFloatGrid_host & v, 
                             const SFloatGrid_host & w,
                             const S_Box          & aabb );

void glRender               (const SEmitter & emitter, 
                             const Sf_Grid  & grid, 
                             const Sf_Grid  & u, 
                             const Sf_Grid  & v, 
                             const Sf_Grid  & w,
                             const S_Box   & aabb );


void glRender              ( const Sf_Grid & grid, 
                             const Sf_Grid & u,
                             const Sf_Grid & v, 
                             const Sf_Grid & w,
                             const S_Box  & aabb);

void glRenderVector(const float3 & v);
void glRenderVector(const float3 & v, const float3 & p);

void glRenderQuad(void);

void glRender(const SLight & light, float3 pos, float dist);

void glRender(CglWorld * pScene);

void glRenderKdTree(KdNode * pKdNode, const S_Box & box, int maxLevel, int curLevel, int nodeIdx, bool empty);
void glRenderKdTree(CSpatialTree * pKdTree, int maxLevel, bool empty);

void glRenderKdTreeLeaf(KdNode       * pKdNode, 
												const S_Box & box, 
												float4       * pVertex,
												int          * pFace,
												int          * pPrimitive,
												int            maxLevel, 
												int            curLevel, 
												int            nodeIdx, 
												bool           empty);

void glRenderKdTreeLeaf(CSpatialTree * pKdTree, int maxLevel, bool empty);

void glRenderBVHTree(BVHNode * pBVHNode, int maxLevel, int curLevel, int nodeIdx, bool empty);
void glRenderBVHTree(CSpatialTree * pBVHTree, int maxLevel, bool empty);

void glRenderBVHTreeLeaf(BVHNode * pBVHNode, 												
												 float4  * pVertex,
												 int     * pFace,
												 uint    * pPrimitive,
												 int       maxLevel,
												 int       curLevel, 
												 int       nodeIdx, 
												 bool      empty);

void glRenderBVHTreeLeaf(CSpatialTree * pBVHTree, int maxLevel, bool empty);

void glRenderKdTreeRayTrace(CSpatialTree * pKdTree, float3 orig, float3 dir, int maxLevel, bool empty);
void glRenderBVHTreeRayTrace(CSpatialTree * pBVH, float3 orig, float3 dir, int maxLevel, bool empty);

#endif